<template>
  <view>
		<!-- <button @click="pullDown">下拉刷新</button>
		<view>这是列表页</view>
		<scroll-view 
		      class="scroll-container" 
		      scroll-y 
		      @scrolltolower="onReachBottom"
		    >
		<view class="box-item" v-for="item in list">
			{{item}}
		</view>
		 </scroll-view> -->
		 <button type="primary" @click="chooseImg">上传图片</button>
		 <!-- <image v-for="item in imgArr" :src="item"></image> -->
		<image v-for="item in imgArr" :src="item" @click="previewImg(item)"></image>    </view>
</template>

<script>
	export default {
	  data() {
		return {
			list:['前端','JAVA','UI','测试','大数据'],
			imgArr:[]
		};
	  },
	  
	  // 页面生命周期函数
	  onLoad(options) {
		console.log('我希望在H5中打印')
	  },
	  onShow() {
		console.log("页面显示了");
	  },
	  onReady() {
		console.log("页面初次渲染完成");
	  },
	  onHide() {
		console.log("页面隐藏了");
	  },
	  onUnload() {
		console.log("页面卸载了");
	  },
	  methods: {
		  pullDown(){
		  		console.log('开启下拉刷新')
				uni.startPullDownRefresh()
		  },
		  chooseImg(){
			  uni.chooseImage({
			  	count:5,
				success:res=>{
					this.imgArr = res.tempFilePaths
				}
			  })
		  },
		  	previewImg(current){
		  			uni.previewImage({
		  				current,
		  				urls:this.imgArr,
		  				loop:true,
		  				indicator:'default'
		  			})
		  		},
		  
		  setStorage(){
			 uni.setStorageSync('id',100)
		  },
		  getStorage(){
		  			  //1.异步调用
		  			 //  uni.getStorage({
		  			 //  key:'id',
		  			// succcess(res){
		  			// 	console.log('获取成功',res.data)
		  			// }
		  			 //  })
		  		 //2.同步调用
		  		 const res = uni.getStorageSync('id')
				 console.log(res)
		  },
		   removeId(){			  uni.removeStorageSync('id')		  },
		},
		
	};
</script>

<style>
	.container {
	  min-height: 100vh; /* 确保容器占满屏幕高度 */
	}
	.scroll-container {
	  height: calc(100vh - 120rpx); /* 减去按钮和标题的高度 */
	}
	.box-item {
	  height: 100px;
	  line-height: 100px;
	  border-bottom: 1px solid #eee;
	  padding-left: 20rpx;
	}
	view{
		color: hotpink;
	}
</style>